﻿using System;
using System.Collections.Generic;
using MyWeb.Data;
using MyWeb.Business;

namespace MyWeb
{
    public partial class AdminMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["lang"] == null)
            {
                Session["lang"] = Global.LangDefault;
            }
            if (Page.User.Identity.Name == null || Page.User.Identity.Name == "")
            {
                Response.Redirect("/logon.aspx");
            }
            else
            {
                if (Session["UserName"] == null || Session["UserName"].ToString() == "")
                {
                    List<User> list = new List<User>();
                    list = UserService.User_GetByUserName(Page.User.Identity.Name);
                    if (list.Count > 0)
                    {
                        Session["FullName"] = list[0].Name.Trim();
                        Session["UserName"] = list[0].Username.Trim();
                        Session["IsAdmin"] = list[0].Admin;
                    }
                }
            }
        }
    }
}